public class Demo25 {
    public static void main(String[] args) {
        Object locker = new Object();
        Thread t1 = new Thread(() -> {
           synchronized(locker){
               System.out.println("wait 之前");
               try {
                   locker.wait();
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
               System.out.println("wait 之后");
           }
        });

        Thread t2 = new Thread(() -> {
           synchronized (locker){
               System.out.println("t2 通知之前");
//               try {
//                   Thread.sleep(1000);
//               } catch (InterruptedException e) {
//                   throw new RuntimeException(e);
//               }
               locker.notify();
               System.out.println("t2 通知之后");
           }
        });
        t1.start();
        t2.start();
    }
}
